package org.charles.zhifou.common.response;

/**
 * <h1>返回工具类</h1>
 *
 * @author charles
 * @version 1.0
 */
public class ResponseUtils {

    /**
     * 成功
     *
     * @param data
     * @param <T>
     * @return
     */
    public static <T> BaseResponse<T> success(T data) {
        return new BaseResponse<>(ResponseCodeEnum.SUCCESS, data);
    }

    /**
     * 失败 (使用默认消息)
     *
     * @param responseCodeEnum
     * @return
     */
    public static BaseResponse<?> error(ResponseCodeEnum responseCodeEnum) {
        return new BaseResponse<>(responseCodeEnum);
    }

    /**
     * 失败 (使用自定义消息)
     *
     * @param responseCodeEnum
     * @return
     */
    public static BaseResponse<?> error(ResponseCodeEnum responseCodeEnum, String message) {
        return new BaseResponse<>(responseCodeEnum, message);
    }
}
